runxpathtool()

function addscript()
{
    findscript=document.createElement('script')
    findscript.setAttribute('src','http://svn.coderepos.org/share/lang/javascript/javascript-xpath/trunk/release/javascript-xpath-latest.js')
    document.body.appendChild(findscript);
}

function adddiv()
{
    maindiv=document.createElement('div');
    maindiv.setAttribute('style','float:left;background-color:#eeeeee;width:300px;hieght:20px;position:fixed;top:1px;z-index:9003');
    
    input=document.createElement('input');
    input.setAttribute('type','text');
    input.setAttribute('id','xpath_input');
    button=document.createElement('a');
    button.setAttribute('onclick','checkxpath()');
    button.innerHTML='Check';
    label=document.createElement('label');
    label.setAttribute('id','xpath_result');
    maindiv.appendChild(input);
    maindiv.appendChild(button);
    maindiv.appendChild(label);
    document.body.appendChild(maindiv);
}

function runxpathtool()
{
    addscript();
    adddiv();
}

function checkxpath()
{
    //xpath_input=document.getElementById('xpath_input');
    var xpathstring=xpath_input.value
    var parser = new XPathParser();
    var xpath = parser.parse(xpathstring);   
    var context = new XPathContext();
    context.expressionContextNode = document.documentElement;
    var result = xpath.evaluate(context);
    //xpath_result=document.getElementById('xpath_input');
    xpath_result.setAttribute('text',result);
}